#include "stdafx.h"
#include "SqlHandle.h"


namespace Otl { namespace Sql
{

sql_handle::sql_handle(_In_ short handleType, const sql_handle & inputHandle)
	: m_handleType{ handleType }
{
	auto error = ::SQLAllocHandle(handleType, inputHandle.m_handle, &m_handle);
	if (error != SQL_SUCCESS)
	{
		// throw
	}
}

void sql_handle::close()
{
	if (m_handle != nullptr)
	{
		::SQLFreeHandle(m_handleType, m_handle);
		m_handle = nullptr;
		m_handleType = 0;
	}
}

}}